package com.mpyy.handler.purchase;

import com.alibaba.fastjson.JSON;
import com.mpyy.pojo.PurchaseStockDesc;
import com.mpyy.service.purchase.SearchRecentStockServiceInter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @version 1.0
 * @Descoription SearchRecentStockHandler
 * @Author CG
 * @date 2022-03-29
 */
@Controller
public class SearchRecentStockHandler {
    @Autowired
    @Qualifier(value = "searchRecentStockServiceImpl")
    private SearchRecentStockServiceInter stockServiceInter;

    @RequestMapping(value = "/searchRecentStock")
    @ResponseBody
    public String searchRecentStock(){
        List<PurchaseStockDesc> purchaseStockDescs = stockServiceInter.searchRecentStock();

        Map<Object,Object> map = new HashMap<>();
        map.put("code",0);
        map.put("msg","");
        map.put("count",purchaseStockDescs.size());
        map.put("data",purchaseStockDescs);
        return JSON.toJSONString(map);
    }

}
